package com.example.gobang2.game;

import jakarta.websocket.Session;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

import java.util.concurrent.ConcurrentHashMap;

@Component
public class OnlineUserManager {
    private ConcurrentHashMap<Integer, WebSocketSession> gameHall = new ConcurrentHashMap<>();
    private ConcurrentHashMap<Integer,WebSocketSession> gameRoom = new ConcurrentHashMap<>();

    public void enterGameHall(int userId, WebSocketSession session){
        gameHall.put(userId,session);
    }

    public void removeGameHall(int userId){
        gameHall.remove(userId);
    }

    public WebSocketSession getSessionFromGameHall(int userId){
        return gameHall.get(userId);
    }

    public WebSocketSession getSessionFromGameRoom(int userId){
        return gameRoom.get(userId);
    }

    public void removeGameRoom(int userId){
        gameRoom.remove(userId);
    }

    public void enterGameRoom(int userId,WebSocketSession session){
        gameRoom.put(userId,session);
    }
}
